package com.yujistu.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * Created by S3YOGA on 2015/11/3.
 */
public class CommonUtils {


    public static boolean hasNetwork(Context context) {
        boolean retVal = false;
        try{
            ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo networkInfo = manager.getActiveNetworkInfo();
            if(null != networkInfo){
                retVal = networkInfo.isAvailable();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return retVal;
    }
}
